﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using VideoPlay.Adapters;

namespace VideoPlay.PhoneClient.ViewModels
{
    public class ViewModelLocator : IDisposable
    {
        private bool disposed;

        private readonly ContainerLocator containerLocator;

        public INavigationService NavigationService
        {
            get
            {
                return this.containerLocator.Container.Resolve<INavigationService>();
            }
        }

        public VideoListViewModel VideoListViewModel
        {
            get
            {
                return this.containerLocator.Container.Resolve<VideoListViewModel>();
            }
        }

        public PlayVideoViewModel PlayVideoViewModel
        {
            get
            {
                return this.containerLocator.Container.Resolve<PlayVideoViewModel>();
            }
        }

        public SearchVideoViewModel SearchVideoViewModel
        {
            get
            {
                return this.containerLocator.Container.Resolve<SearchVideoViewModel>();
            }
        }

        public VideoShareFBViewModel VideoShareFBViewModel
        {
            get
            {
                return this.containerLocator.Container.Resolve<VideoShareFBViewModel>();
            }
        }

        public ViewModelLocator()
        {
            this.containerLocator = new ContainerLocator();
        }

        public void Dispose()
        {
            this.Dispose();
            //GC.SuppressFinalize(this);
        }

        protected virtual void Dispose(bool disposing)
        {
            if (this.disposed)
            {
                return;
            }

            if (disposing)
            {
                this.containerLocator.Dispose();
            }

            this.disposed = true;
        }
    }
}
